<template>
    <div>
        <breadcrumb :routerList="routerList"></breadcrumb>
        <btn-area @reloadFun="reloadFun" @searchFun="searchFun"/>
        <tab-list :tabData="productsData" @productChange="reloadProducts" />
        <pagination :total="total" @sizeChange="sizeFun" @currentPage="curPage"></pagination>
    </div>
</template>

<script>
    import breadcrumb from '@/components/breadcrumb.vue'
    import btnArea from './components/product-button.vue'
    import tabList from './components/product-list.vue'
    import pagination from '@/components/paginationSizeChange.vue'

    export default {
        name: "integral-product",
        components: {
            breadcrumb,
            btnArea,
            tabList,
            pagination
        },
        data() {
            return {
                routerList: [
                    {
                        path: '',
                        name: '积分管理'
                    },
                    {
                        path: '',
                        name: '积分商品管理'
                    }
                ],
                p: 1,
                num: this.$store.state.pageNum,
                total: 0,
                productsData: [],
                like: ''
            }
        },
        created() {
            this.getProducts()
        },
        methods: {
            async getProducts() {
                const data = await this.$Http.getIntegralProducts(
                    {
                        supplier_id: this.$store.state.supplier_id,
                        like: this.like,
                        p: this.p,
                        num: this.num
                    }
                )
                // console.log(data)
                this.total = Number( data.count )
                this.productsData = data.list
            },
            sizeFun(val) {
                this.num = val
                this.getProducts()
            },
            curPage(val) {
                this.p = val
                this.getProducts()
            },
            reloadProducts() {
                // console.log('reload');
                this.getProducts()
            },
            reloadFun() {
                this.getProducts()
            },
            searchFun(val) {
                this.like = val
                this.getProducts()
            }
        }
    }
</script>

<style scoped>

</style>
